package edu.ynu.hhy.architectureclass.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import edu.ynu.hhy.architectureclass.common.entity.BaseEntity;
import edu.ynu.hhy.architectureclass.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;

@Entity
@Getter
@Setter
@Where(clause = "is_deleted = 0")
public class Greenhouse extends LogicEntity {
    private Long id; // 大棚ID

    @Column(nullable = false)
    private String name; // 大棚名称

    private BigDecimal area; // 面积(平方米)

    private String address; // 地址


    @JsonManagedReference
    @OneToMany(mappedBy = "greenhouse", cascade = CascadeType.ALL)
    private List<Device> devices; // 大棚内的设备列表

    @Transient // 表示该字段不持久化到数据库
    private int deviceCount; // 设备数量

}
